﻿using System;
using Glue;
using Xunit;

namespace GlueTests.MapperTests
{
    public class When_mapping_from_a_method
    {
        private readonly Mapping<DomainPerson, GuiPerson> mapping;

        public class GuiPerson
        {
            public String FirstName { get; set; }
        }

        public class DomainPerson
        {
            public String GetGivenName() {return "NameFromAMethod"; }
        }

        public When_mapping_from_a_method()
        {
            mapping = new Mapping<DomainPerson, GuiPerson>();
            mapping.RelateTowardsRight(x=>x.GetGivenName(),y=>y.FirstName);
        }

        [Fact]
        public void Should_map_like_normal()
        {
            var domainPerson = new DomainPerson();
            var guiPerson = mapping.Map(domainPerson, new GuiPerson());
            Assert.Equal(domainPerson.GetGivenName(),guiPerson.FirstName);
        }
    }
}
